package com.ruoyi.system.service.impl;

import java.util.ArrayList;
import java.util.List;

import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.system.domain.SysOcrTemplatePlace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysOcrTemplatePointMapper;
import com.ruoyi.system.domain.SysOcrTemplatePoint;
import com.ruoyi.system.service.ISysOcrTemplatePointService;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-29
 */
@Service
public class SysOcrTemplatePointServiceImpl implements ISysOcrTemplatePointService 
{
    @Autowired
    private SysOcrTemplatePointMapper sysOcrTemplatePointMapper;

    /**
     * 查询【请填写功能名称】
     * 
     * @param pointId 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public SysOcrTemplatePoint selectSysOcrTemplatePointByPointId(Long pointId)
    {
        return sysOcrTemplatePointMapper.selectSysOcrTemplatePointByPointId(pointId);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param sysOcrTemplatePoint 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<SysOcrTemplatePoint> selectSysOcrTemplatePointList(SysOcrTemplatePoint sysOcrTemplatePoint)
    {
        return sysOcrTemplatePointMapper.selectSysOcrTemplatePointList(sysOcrTemplatePoint);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param sysOcrTemplatePoint 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertSysOcrTemplatePoint(SysOcrTemplatePoint sysOcrTemplatePoint)
    {
        return sysOcrTemplatePointMapper.insertSysOcrTemplatePoint(sysOcrTemplatePoint);
    }

    @Override
    public void insertOrUpdateSysOcrTemplatePoint(SysOcrTemplatePoint point) {
        if (point.getPointId() == null){
            this.insertSysOcrTemplatePoint(point);
        }else{
            SysOcrTemplatePoint sysOcrTemplatePoint = this.selectSysOcrTemplatePointByPointId(point.getPointId());
            if (sysOcrTemplatePoint != null){
                BeanUtil.copyProperties(point, sysOcrTemplatePoint);
                this.updateSysOcrTemplatePoint(sysOcrTemplatePoint);
            }
        }
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param sysOcrTemplatePoint 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateSysOcrTemplatePoint(SysOcrTemplatePoint sysOcrTemplatePoint)
    {
        return sysOcrTemplatePointMapper.updateSysOcrTemplatePoint(sysOcrTemplatePoint);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param pointIds 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteSysOcrTemplatePointByPointIds(Long[] pointIds)
    {
        return sysOcrTemplatePointMapper.deleteSysOcrTemplatePointByPointIds(pointIds);
    }

    @Override
    public int deleteSysOcrTemplatePointByPoints(List<SysOcrTemplatePoint> points) {

        List<Long> idList = new ArrayList<>();
        for (SysOcrTemplatePoint point : points) {
            idList.add(point.getPointId());
        }
        Long[] idArr = idList.toArray(new Long[0]);
        return deleteSysOcrTemplatePointByPointIds(idArr);
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param pointId 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteSysOcrTemplatePointByPointId(Long pointId)
    {
        return sysOcrTemplatePointMapper.deleteSysOcrTemplatePointByPointId(pointId);
    }
}
